package LeetcodeTest_forty_five;
//628. 三个数的最大乘积
import java.util.Arrays;

public class maximumProduct
{
    public static void main(String[] args)
    {
        int[] nums={-1,-3,1,4,6,0};
        int i = Solution.maximumProduct(nums);
        System.out.println(i);
    }
}
class Solution
{
    public static int maximumProduct(int[] nums)
    {
        int n=nums.length;
        Arrays.sort(nums);
        if(nums[0]>=0 || nums[n-1]<=0)
        {
            return nums[n-1]*nums[n-2]*nums[n-3];
        }
        else
        {
            return Math.max(nums[n-1]*nums[n-2]*nums[n-3],nums[0]*nums[1]*nums[n-1]);
        }
    }
}
